package study.itheima.myjdbc;

import java.sql.*;

public class JdbcDemo1 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //注册驱动
        Class.forName("com.mysql.jdbc.Driver");
        //数据库连接
        Connection con = DriverManager.getConnection("jdbc:mysql://192.168.23.129:3306/db1", "root", "ljx19960802");
        //获取执行者对象
        Statement sm = con.createStatement();
        ResultSet rs = sm.executeQuery("select * from users");
        while (rs.next()){
            System.out.println(rs.getInt("id")+"\t"+rs.getString("username"));
        }
        rs.close();
        sm.close();
        con.close();

    }
}
